package day_01;

/**
 * DoubleCheck Singleton
 */
public class DoubleCheckSingleton {
    private DoubleCheckSingleton(){}
    private volatile static DoubleCheckSingleton singleton;

    public static DoubleCheckSingleton getSingleton(){
        if(singleton == null){
            synchronized (DoubleCheckSingleton.class) {
                if(singleton == null){
                    singleton = new DoubleCheckSingleton();
                }
            }
        }
        return singleton;
    }

    public static void main(String[] args) {
        System.out.println(DoubleCheckSingleton.getSingleton().equals(DoubleCheckSingleton.getSingleton()));
    }
}
